<?php
class Pageley_Tag_Link extends Pageley_Tag_Abstract implements Pageley_Tag_Parametrizable {
    
    private $controller;
    private $parameters;
    
    public function __construct() {
        $this->parameters = new Pageley_Util_ArrayMap();
    }
    
    public function execute() {
        $link = "./dispatcher.php";
        if($this->controller != null) {
            $link .= "?controller=" . $this->controller;
            foreach($this->parameters as $name => $value) {
                $link .= "&" . $name . "=" . urlencode($value);
            }
        }
        return $link;
    }
    
    public function setController($controller) {
        $this->controller = $controller;
    }
    
    public function setParameter($name, $value) {
        $this->parameters->put($name, $value);
    }
}